Repository navigation
Conversation
|
hi @cloud-fan -- the values buffer and the validity bitmap are not fully comparable because the bit padding in the bitmap falls inside word boundaries, whereas in the values buffer, in general this is not the case. For example, one may use hardware popcount on the valid bits to compute null count, so failing to initialize the padding bits to 0 may yield incorrect results (or you would need to use a "slow popcount" on a word with padding). For example, for a length-50 array, all the valid bits fit in a single 64-bit word, but the final 14 bits need to be set to 0 for the result of popcount to yield a correct answer for the number of valid values in that word. The values buffer by contrast does not have this issue, because the "comparable range" of the allocated buffer does not include the padding. So in the same case of a length-50 int32 vector, we might have validity bitmap: 8 bytes (or 64 bytes with padding) so, should you wish to compare or use SIMD operations on the values buffer, the 56 bytes of padding should not have any bearing on the result. the same isn't true of the bitmap Interested in the opinions of others -- having to memset the padding to 0 seems potentially onerous, especially if there will rarely be any code that needs to inspect it? |
|
Hey @wesm, for Ray padding to 0 is very helpful. We use Arrow's IPC mechanism to lay out Python objects in memory and compute a hash on the bytes to determine if tasks are deterministic or not in case a task gets rerun on the same input (for example for object reconstruction). In fact I'm investigating right now why the serialization became non-deterministic after rebasing on the latest arrow and this is a good candidate. So either having a compiler flag that makes Arrow initialize padding to zero would be great (if we don't want to put the performance penalty on everybody), or maybe even make it part of the format like this. -- Philipp. |
|
Hi @wesm , yes this makes sense, padding with 0 is not necessary and may has performance penalty. But I think deterministic is also an important feature, e.g. we may run equality check for 2 values in SQL query engine, and if the binary format is deterministic, we can just compare the binary, which can be very fast. If the binary format is non-deterministic, then we have to read the metadata and only check the "comparable range". |
|
@cloud-fan can you give me a more concrete example of the kind of problem this might cause for you? When you say "equality check for 2 values", is there a situation where the byte range to compare would not be deterministic? I'm trying to understand when you would have behavior that depends on the data contained in the padding bytes. This is closely related to the problem of applying null bitmasks to data. For example, suppose we had: You can turn this into by changing the bitmap on the array, but otherwise leaving the values buffer unchanged. If you built this array from scratch, you would have a values buffer
whereas the one with the bitmap overlay still has internally
but semantically, the arrays are equal because the Within a particular implementation of Arrow, it may be a good idea to initialize memory to 0, but to say that a buffer is "invalid" according to the format if its padding is nonzero seems problematic. If I compute a zero-copy slice of an array, and then write out its contents in an IPC message, do I then need to verify that the padding bytes going over the wire have been zero'd out? |
|
To be clear, I think it is a good idea for an implementation to be internally consistent about this (for example, we are already zero-ing out the memory in C++ allocations -- @pcmoritz probably stumbled on a case where we forgot to), so this is more a question of what requirements we are placing on data that goes into a stream or other type of RPC message |
|
By "deterministic", I mean for a certain logical value(e.g. But if we build a value from scratch(e.g. build For some frameworks like Spark, which builds the columnar in-memory data block and never change it, I think "deterministic" does have some values. @wesm what do you think? |
This is what I meant by being "internally consistent". So if you are both the producer and the consumer of the data, then you can choose to do extra work to guarantee that the "hidden" byte ranges have a deterministic value. But if you want to send and receive Arrow data to / from other Arrow implementations, then in general you cannot rely on these unspecified byte ranges having a particular value. Note that this format document Layout.md is about specifying the memory format that is guaranteed in an IPC setting. That is, data sent from one Arrow implementation to another. So if you want to add extra restrictions in the C++ implementation, or the Spark implementation, you are free to do so, so long as you comply with the guarantees in this document. |
|
@wesm thanks for your time! makes sense to me, I'm closing this |
|
No problem -- it's a reasonable expectations for implementations to produce deterministic memory layouts (e.g. we just fixed non-determinism in the C++ implementation #405), so I think as long as developers have the ability to do that then all is good. But if you receive some "foreign" memory you should be more careful about what assumptions are made. |
This will enable most of the outstanding PRs to be rebased and then merged Close apache#384 Close apache#394 Author: Wes McKinney <wes.mckinney@twosigma.com> Closes apache#397 from wesm/PARQUET-1104 and squashes the following commits: 4106c5b [Wes McKinney] Include boost_system in static toolchain until ARROW-1536 resolved 005ee74 [Wes McKinney] Account for internal API change in ARROW-1511 3cab00d [Wes McKinney] Change MutableBuffer to Buffer to account for deprecation in ARROW-1402 7cd9702 [Wes McKinney] Upgrade to Apache Arrow 0.7.0 RC0 Change-Id: I6d0af9910da4d123ac66ec1a58a0de96c7ecaa95
It looks weird that we use 0 padding for null bits, but use
unspecifiedpadding for value buffer. I think we should always use 0 for padding, to be more consistent.I haven't checked about the implementations, do they already use 0 for padding?
Further more, shall we use 0 everywhere when
unspecifiedis used?